﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_DangKy : System.Web.UI.UserControl
{
    private UsersBLL usersBLL;

    protected void Page_Load(object sender, EventArgs e)
    {
        this.usersBLL = new UsersBLL();

    }

    protected void btnRegister_Click(object sender, EventArgs e)
    {
        string username = this.txtUsername.Text.Trim();
        string password = this.txtPassword.Text.Trim();
        string email = this.txtEmail.Text.Trim();

        bool result = this.usersBLL.GetIUsers.CreateUser(username, password, email);

        if (result)
        {
            Session["User"] = this.usersBLL.GetIUsers.GetUserByUsername(username);
            Response.Redirect("RegisterSuccess.aspx");

        }
        else
            Response.Redirect("Fail.aspx");
    }
}